home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap06
/
ValueInJava.java
< prev
next >
Wrap
Text File
|
1996-09-29
|
989b
|
37 lines
//
// parameters are inside Java codes.
//
import vrml.*;
import vrml.node.*;
import vrml.field.*;
public class ValueInJava extends Script{
SFVec3f set_translation;
float currentPosition[] = new float[3];
float offset[] = new float[3];
public void initialize(){
// get the reference of the event out 'set_translation'.
set_translation = (SFVec3f)getEventOut("set_translation");
// initialize currentPosition and offset.
currentPosition[0] = 0.0f;
currentPosition[1] = 0.0f;
currentPosition[2] = 0.0f;
offset[0] = 1.0f;
offset[1] = 0.0f;
offset[2] = 0.0f;
}
public void processEvent(Event e){
if(e.getName().equals("touched") == true){
currentPosition[0] += offset[0];
currentPosition[1] += offset[1];
currentPosition[2] += offset[2];
set_translation.setValue(currentPosition);
}
}
}